var jCategoryTree;
$j(document).ready(function () {
	
});


//点击树节点动作
function clickTreeItemAction(type){
	var parentId = jCategoryTree.getSelected()[0].id;
	//var treeItem=getCategoryItemJSON(jCategoryTree.getSelected());	
	searchResources(type,true,{'parentId':parentId});
}

//验证函数
function validateSearchCriteria(){
	return true;
}

//批量删除
function deleteResources(type){
	var paraData=$j("#appResourceListForm :input[name='multiIds']").serializeArray();
	if(paraData.length>0){
		var itemNames = fnGetSelectedItemNames();
		if(confirm( __FMT.common_message_confirmDeleteThis+ " " + itemNames+"?")){
			window.document.appResourceListForm.action=__ctxPath+"/system/"+type+".html?doAction=multiDelete";
			window.document.appResourceListForm.submit();
		}
	}else{
		alert("请选择要删除的权限!");
	}
}

//搜索文章 isNew标示是否新的搜索,param标示是否自定义参数搜索
function searchResources(type,isNew,param){
	var postData;
	var url=__ctxPath+"/system/"+type+"/dialog.html?doAction=search";
	if(isNew){
		url+="&btnSearch=1";
		if(null==param){
			if(validateSearchCriteria()){
				//有搜索结果搜索
    postData = $j('#resourceSearchCriteria :input').serializeArray();
				$j("#resourceResults").load(url,postData);  
   }else{
   	return;
   }
		}else{
	  //postData={'parentId':param.parentId};
  	$j("#resourceResults").load(url,param);
		}
	}else{
		postData = $j('#resourceResults :input').serializeArray();
		$j("#resourceResults").load(url,postData);
	} 
	
}
//刷新列表
function refreshResourceList(type){
	searchResources(type,false);
}

